package storage

import (
	"errors"
	"fmt"
)

var (
	ErrStorageTypeInvalid = errors.New("cache: storage type is invalid")
	ErrStorageDriverIsNil = errors.New("cache: storage driver is nil")

	ErrTraverseFnIsNil = errors.New("cache: traverse function is nil")
)
var (
	ErrKeyIsEmpty        = errors.New("cache: key is empty")
	ErrKeyIsExists       = errors.New("cache: key is exists")
	ErrKeyNotExists      = errors.New("cache: key not exists")
	ErrKeyExpired        = errors.New("cache: key is expired")
	ErrKeyKindInvalid    = errors.New("cache: key/value kind is invalid")
	ErrSetExpireDuration = errors.New("cache: set 'expire' duration must be greater than 1 second")
	ErrSetExpireAt       = errors.New("cache: set 'expiredAt' time must be in the future")
)

var (
	ErrValueIsNil        = errors.New("cache: value is nil")
	ErrValueIsNotInteger = errors.New("cache: value is not an integer or out of range")
	ErrValueTooLarge     = errors.New("cache: value size is too large")
	ErrRefValueIsNil     = errors.New("cache: refValue is nil")

	ErrValueDataInvalid   = errors.New("cache: value data is invalid")
	ErrValueNotString     = errors.New("cache: value type is not string")
	ErrValueNotBool       = errors.New("cache: value type is not bool")
	ErrValueNotFloat64    = errors.New("cache: value type is not float64")
	ErrValueNotFloat32    = errors.New("cache: value type is not float32")
	ErrValueNotInt64      = errors.New("cache: value type is not int64")
	ErrValueNotInt32      = errors.New("cache: value type is not int32")
	ErrValueNotInt16      = errors.New("cache: value type is not int16")
	ErrValueNotInt8       = errors.New("cache: value type is not int8")
	ErrValueNotInt        = errors.New("cache: value type is not int")
	ErrValueNotUint64     = errors.New("cache: value type is not uint64")
	ErrValueNotUint32     = errors.New("cache: value type is not uint32")
	ErrValueNotUint16     = errors.New("cache: value type is not uint16")
	ErrValueNotUint8      = errors.New("cache: value type is not uint8")
	ErrValueNotUint       = errors.New("cache: value type is not uint")
	ErrValueNotTime       = errors.New("cache: value type is not time.Time")
	ErrValueNotDuration   = errors.New("cache: value type is not time.Duration")
	ErrValueNotWeekday    = errors.New("cache: value type is not time.Weekday")
	ErrValueNotMonth      = errors.New("cache: value type is not time.Month")
	ErrValueNotComplex64  = errors.New("cache: value type is not complex64")
	ErrValueNotComplex128 = errors.New("cache: value type is not complex128")
	ErrValueNotIP         = errors.New("cache: value type is not net.IP")
	ErrValueNotBytes      = errors.New("cache: value type is not []byte")
	ErrValueNotSetString  = errors.New("cache: value type is not set<string>")
	ErrValueNotSetInt     = errors.New("cache: value type is not set<int64>")
	ErrValueNotSerializer = errors.New("cache: value type is not serializer")
	ErrValueMarshal       = errors.New("cache: value Marshal error")
	ErrValueUnmarshal     = errors.New("cache: value Unmarshal error")
)

func ErrValueToNumberOutOfRange[T TypeNumber](toType string, numericVal T) error {
	return fmt.Errorf("cache: unable to %s, numeric value '%v' out of range", toType, numericVal)
}
func ErrValueUnableToType[T1, T2 Kind | string](srcType T1, toType T2) error {
	return fmt.Errorf("cache: unable to cast value of type '%s' to type '%s'", srcType, toType)
}
